package com.gtp.kafka.producer;

import java.util.Map;

import org.apache.kafka.clients.producer.ProducerInterceptor;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.clients.producer.RecordMetadata;

//消息拦截器
@SuppressWarnings("rawtypes")
public class MyProducerInterceptor implements ProducerInterceptor{

	@Override
	public void configure(Map<String, ?> configs) {
		System.out.println("拦截器-初始化:"+configs);
	}

	@Override
	public ProducerRecord onSend(ProducerRecord record) {
		System.out.println("拦截器-发消息:"+record);
		return record;
	}

	@Override
	public void onAcknowledgement(RecordMetadata metadata, Exception exception) {
		System.out.println("拦截器-ack");
	}

	@Override
	public void close() {
		System.out.println("拦截器-关闭");
	}

}
